const BinaryTree = require('../utils/binaryTree')
let arr = [5,4,8,11,null,13,4,7,2,null,null,null,1]
let rootObj = new BinaryTree(arr)
var hasPathSum = function (root, targetSum) {
  function dfs(node, currentSum) {
    if (!node) {
      return false
    }
    currentSum += node.val
    if (!node.left && !node.right) {
      return currentSum === targetSum
    }
    return dfs(node.left, currentSum) || dfs(node.right, currentSum)
  }
  return dfs(root, 0)
}
const result = hasPathSum(rootObj.root,22)
console.log("🚀 ~ result:", result)
